/**
 * Copyright (c) 2005-2008 旭鸣软件
 * All rights reserved. 
 */
/**
 * File：PageObjectSet.java
 * History:
 *       2010-5-25: Initially created, tangkf.
 */
package com.xteam.db.page;

import java.io.Serializable;
import java.util.List;

/**
 * 分页处理的对象集合 其中包含两部分内容： 1. 分页信息本身，用来描述分页的相关参数 2. 对象集合，代表了按分页参数取得的对象集合 当返回的时候才不至于只返回了对象集合而没有分页的相关信息
 * @author tangkf
 */
public class PageObjectSet<E> implements Serializable {
	
	private static final long	serialVersionUID	= 1L;

	private int					index				= 0;
	private int					size				= 30;
	private long				rowCount			= 0;

	private List<E>				resultList			= null;

	public PageObjectSet() {
	}

	public PageObjectSet(long count, List<E> list) {
		this.rowCount = count;
		this.resultList = list;
	}

	/**
	 * @return 属性resultList的值.
	 */
	public List<E> getResultList() {
		return this.resultList;
	}

	/**
	 * @param resultList 属性resultList.
	 */
	public void setResultList(List<E> resultList) {
		this.resultList = resultList;
	}

	/**
	 * @return 属性fIndex的值.
	 */
	public int getIndex() {
		return this.index;
	}

	/**
	 * @return 属性pageSize的值.
	 */
	public int getPageSize() {
		return this.size;
	}

	/**
	 * @return 属性rowCount的值.
	 */
	public long getRowCount() {
		return this.rowCount;
	}

	/**
	 * @param rowCount 属性rowCount.
	 */
	public void setRowCount(long rowCount) {
		this.rowCount = rowCount;
	}

	/**
	 * @return 属性pageCount的值.
	 */
	public int getPageCount() {
		int c = 0;
		if (this.rowCount % size != 0)
			c = 1;
		return (int) (this.rowCount / size) + c;
	}

	/**
	 * @return 属性size的值.
	 */
	public int getSize() {
		return this.size;
	}

	/**
	 * @param size 属性size.
	 */
	public void setSize(int size) {
		this.size = size;
	}

	/**
	 * @param index 属性index.
	 */
	public void setIndex(int index) {
		this.index = index;
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("PageObjectSet [index=");
		builder.append(index);
		builder.append(", resultList=");
		builder.append(resultList);
		builder.append(", rowCount=");
		builder.append(rowCount);
		builder.append(", size=");
		builder.append(size);
		builder.append("]");
		return builder.toString();
	}
}
